//登陆功能的实现
function tz_user_login(obj){
	var account = $("#tmaccount").val();
	var password = $("#tmpassword").val();
	var params = {
			"account":account,
			"password":password
			};
	
	/*******************验证开始************************/
	//文本框不允许为空---按钮触发
	if (account == "" || account == undefined || account == null) {
		alert("account==="+account);
		/* $("#warn").css({ display: 'block' }); */
		tm_showmessage("warn");
		$("#tmaccount").select();
		return;
	}
	else {
		if (password == "" || password == undefined || password == null) {
			alert("tmpassword==="+password);
			/* $("#warn2").css({ display: 'block' }); */
			tm_showmessage("warn2");
			$("#tmpassword").select();
			return;
		}
	}
	
	//显示错误信息
	function tm_showmessage(id){
		$("#"+id).show().html().stop(true,true).fadeOut(3000);
	}
	/*******************验证结束************************/
	
	//发用登录ajax
	 $.ajax({
		 type:"post",
		 url:"${basePath}/stage/login",
		 data:params,
		 success:function(data){
			 if(data=="error"||data=="null"){
				 alert("请输入完整的帐号和密码！");
				 $("#tmaccount").select();
				 $("#tmpassword").val("");
			 }else if(data=="fail"){
				 alert("帐号和密码不一致请重新输入！");
				 $("#tmaccount").select();
				 $("#tmpassword").val("");
				 tm_showmessage("warn");
			 }else{
				 window.location.href = "${basePath}/stage/index";
			 }
		 }
	 });
}  
	
$(function(){
	//按下Enter建触发登陆按钮
	$(document).keydown(function(e){
		if(e.keyCode==13){
			tz_user_login();
		}
	});
}); 